/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package networkrespnse;

import core.ParameterDecoder;

import utils.Utils;

/**
 *
 * @author Kvest
 */
public class RegisterOnTaxiParkingResponse extends Response
{
    private int parkingUID;
    private String parkingName;
    private String result;
    private int numberInQueue;
    
    public RegisterOnTaxiParkingResponse(byte[] data)
    {
        super(REGISTER_ON_TAXI_PARKING_RESPONSE);
        parkingUID = -1;
        parkingName = "";
        result = "";
        numberInQueue = -1;

        parse(data);
    }

    protected void parse(byte[] data)
    {
        byte[] body,temp;
        int index,size;
        //��������  body
        body = ParameterDecoder.getTransferBody(data);
        temp = new byte[4];
        index = 0;
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        index += Utils.byteToInt(temp);
        //�������� ParkingUID
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        parkingUID = Utils.byteToInt(temp);
        //�������� ParkingName
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        size = Utils.byteToInt(temp);
        temp = new byte[size];
        for (int i=0;i<size;i++)
        {
                temp[i] = body[index++];
        }
        parkingName = Utils.byteToString(temp);
        //�������� Result
        temp = new byte[4];
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        size = Utils.byteToInt(temp);
        temp = new byte[size];
        for (int i=0;i<size;i++)
        {
                temp[i] = body[index++];
        }
        result = Utils.byteToString(temp);

        //Номер в очереди
        if ((index+3) < body.length)
        {
            temp = new byte[4];
            for (int i=0;i<4;i++)
            {
                temp[i] = body[index++];
            }
            numberInQueue = Utils.byteToInt(temp);
        }

        System.gc();
    }

    public int getParkingUID()
    {
        return parkingUID;
    }

    public int getNumberInQueue()
    {
        return numberInQueue;
    }

    public String getParkingName()
    {
        return parkingName;
    }

    public String getResult()
    {
        return result;
    }
}
